Skip to content

fix(core): fix broken error handling in getManifestJson#3556

Merged
danpeen merged 2 commits intomodule-federation:mainfrom
foxylion:bugfix/fix-error-handling-after-resolve
Mar 4, 2025
Merged

fix(core): fix broken error handling in getManifestJson#3556
danpeen merged 2 commits intomodule-federation:mainfrom
foxylion:bugfix/fix-error-handling-after-resolve

Conversation

@foxylion
Copy link
Contributor

Description

Failures in loading the manifest file does not return the actual error, but a useless function reference to plugins. Error handling is not possible. The "err" variable is now passed in as "error".

Related Issue

No issue yet created.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation.

Failures in loading the manifest file does not return the actual error, but a useless function
reference to plugins. Error handling is not possible. The "err" variable is now passed in as
"error".
@changeset-bot
Copy link

changeset-bot bot commented Feb 28, 2025

⚠️ No Changeset found

Latest commit: 3e03108

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link

netlify bot commented Feb 28, 2025

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit 3e03108
🔍 Latest deploy log https://app.netlify.com/sites/module-federation-docs/deploys/67c6c92d45611600088a1152
😎 Deploy Preview https://deploy-preview-3556--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@foxylion
Copy link
Contributor Author

@2heal1 @ScriptedAlchemy could this get merged to allow error handling in a proper way? :-)

@danpeen danpeen merged commit 0e9b854 into module-federation:main Mar 4, 2025
4 checks passed
@2heal1 2heal1 mentioned this pull request Mar 17, 2025
@koen-dev
Copy link

@foxylion thanks for fixing this! Do you have any example(s) of how to handle this error?

@foxylion foxylion deleted the bugfix/fix-error-handling-after-resolve branch March 18, 2025 19:57
@foxylion
Copy link
Contributor Author

foxylion commented Mar 18, 2025

@koen-dev You'll need to implement a module federation plugin. An example could be:

import type { FederationRuntimePlugin } from '@module-federation/enhanced/runtime';

const logger = getLogger('module-federation/error-handling-plugin');

export const errorHandlingPlugin = (): FederationRuntimePlugin => {
  return {
    name: 'error-handling-plugin',
    errorLoadRemote(args) {
      // In the future, we'll need to filter down for real errors, but we need to figure out what is a real error and what not
      logger.captureException(args.error, { info: 'tracked by module-federation/error-handling-plugin/errorLoadRemote' });
      return args;
    },
  };
};

Then register it either and build-time (using plugins: [...]) or at runtime (using registerPlugins([...]) from @module-federation/enhanced/runtime).

In our case we are forwarding the errors to Sentry. Some of them will be supressed (e.g. network fetch errors, others might need triage).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants